import java.util.Arrays;
import java.util.Random;

public class Test {
    public static void orderArray(int[] array){
        for(int i=0;i<array.length;i++){
            //array[i]=i;
            array[i]=array.length-1-i;
        }
    }
    public static void notOrderArray(int[] array){
        Random random = new Random();
        for(int i=0;i<array.length;i++){
            array[i]=random.nextInt(100000);
        }
    }
    public static void testInsert(int[] array){
        array= Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.insetSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("直接插入排序耗时："+(endTime-startTime));
    }
    public static void testShellSort(int[] array){
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.shellSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("希尔排序耗时："+(endTime-startTime));
    }
    public static void testSelectSort(int[] array){
        array=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        Sort.selectSort(array);
        long endTime=System.currentTimeMillis();
        System.out.println("直接选择排序耗时："+(endTime-startTime));
    }
    public static void testSelectSort2(int[] array){
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.selectSort2(array);
        long endTime = System.currentTimeMillis();
        System.out.println("优化后的选择排序耗时："+(endTime-startTime));
    }
    public static void testHeapSort(int[] array){
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.heapSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("堆排序耗时："+(endTime-startTime));
    }
    public static void testBubbleSort(int[] array){
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.bubbleSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("冒泡排序耗时："+(endTime-startTime));
    }
    public static void main(String[] args){
        testSimple();
        //testOther();
    }
    public static void testSimple(){
        int[] array={1,5,8,2,6,8,2,7,4,4,7,8,9};
        System.out.println("排序前："+Arrays.toString(array));
        Sort.countSort(array);
        System.out.println("排序后："+Arrays.toString(array));
    }
    public static void testOther(){
        int[] array = new int[100000];
        notOrderArray(array);
        //orderArray(array);
        testInsert(array);
        testShellSort(array);
    }
}
